import {isObject} from './index';

export const setStorage = (key, value) => {
    value = isObject(value) ? JSON.stringify(value) : value
    localStorage.setItem(key, value)
}

export const getStorage = (key) => {
    try {
        return JSON.parse(localStorage.getItem(key))
    } catch (error) {
        return localStorage.getItem(key)
    }
}

export const removeStorage = (key) => localStorage.removeItem(key)

export const clearStorage = () => localStorage.clear()